<template>
	<div class="center_right">
		<div class="center_rightlabel">
			影像报告
		</div>
		<div class="center_rightcont beautifulScroll">
			<div class="center_rightable">
				<div class="center_rightable_search">
					<el-input @keyup.enter.native="currentChange(1)" placeholder="请输入病例名称" prefix-icon="el-icon-search" v-model="caseName" size='small' style="width:200px;margin: 0 10px 0 0;" clearable/>
					<span class="index_mainsearch_label">提交时间</span>
					<el-date-picker v-model="startEnd" @change='currentChange(1)' type="daterange" value-format='yyyy-MM-dd' size='small' start-placeholder="开始日期" end-placeholder="结束日期" style="width:300px;margin: 0 10px 0 0;" clearabled></el-date-picker>
					<el-button type="primary" @click="currentChange(1)" size='small'>搜索</el-button>
					<el-button type="primary" @click="research" size='small'>重置</el-button>
				</div>
				<el-table :data="dataList" border>
					<el-table-column label="序号" align='center' width='60'>
						<template slot-scope="scope">
							{{scope.$index +1 }}
						</template>
					</el-table-column>
					<el-table-column prop="number" label="病历号" align='center'>
					</el-table-column>
					<el-table-column prop="caseName" label="病例名称" align='center'>
					</el-table-column>
					<el-table-column prop="createTime" label="提交时间" align='center'>
					</el-table-column>
					<el-table-column prop="evaluateTime" label="评分时间" align='center'>
					</el-table-column>
					<el-table-column label="操作" align="center" width='200'>
						<template slot-scope="scope">
							<el-button type="text" @click="openView(scope.row)">查看</el-button>
							<!--<el-button type="text" @click="deleteItemReport(scope.row)">删除</el-button>-->
						</template>
					</el-table-column>
				</el-table>
				<div class="index_mainpages top">
					<el-pagination hide-on-single-page background @current-change="currentChange" :current-page="pageNum" :page-size="pageSize" layout="total,  prev, pager, next, jumper" :total="total">
					</el-pagination>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import { reportList } from '@/api/center.js'
	import { deleteReport } from '@/api/case.js'
	export default {
		data() {
			return {
				startEnd: [],
				caseName: '',
				dataList: [],
				pageNum: 1,
				pageSize: 8,
				total: 0,
			}
		},
		created() {
			this.getDataList();

		},
		mounted() {

		},
		methods: {
			openView(item) {
				this.$router.push({
					name: 'centercase',
					query: {
						reportId: item.reportId,
						caseId: item.caseId,
					}
				})
			},
			research() {
				this.caseName = '';
				this.startEnd = [];
				this.currentChange(1)
			},
			currentChange(pageNum) {
				this.pageNum = pageNum;
				this.getDataList();
			},
			getDataList() {
				reportList({
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					caseName: this.caseName,
					startTime: this.startEnd && this.startEnd.length == 2 ? this.startEnd[0] : null,
					endTime: this.startEnd && this.startEnd.length == 2 ? this.startEnd[1] : null,
				}).then(res => {
					this.dataList = res.data.list;
					this.total = res.data.total;
				})
			},
			deleteItemReport(item) {
				this.$confirm('确认删除此诊断报告吗？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
				}).then(() => {
					deleteReport({
						reportId: item.reportId,
					}).then(res => {
						if(res.code == 200) {
							this.getDataList()
						} else {
							this.$message({
								type: 'error',
								message: res.message
							})
						}
					})
				}).catch(() => {})
			},
		},
	}
</script>